{include file="public/head" /}
</head>

<body class="login-bg">

    <div class="login layui-anim layui-anim-up">
        <div class="message">皇家宠物-管理登录</div>
        <div id="darkbannerwrap"></div>

        <form method="post" class="layui-form" action="{:url('check')}" method="post">
            <input type="hidden" name="__token__" value="{$token}" />
            <input name="name" placeholder="用户名" type="text" lay-verify="required" class="layui-input">
            <hr class="hr15">
            <input name="password" lay-verify="required" placeholder="密码" type="password" class="layui-input">
            <hr class="hr15">
            <div class="layui-form-item">
                <input type="text" class="layui-form-label" name="code" placeholder="验证码" style="width:50%;"  lay-verify="required">
            
                    <div  class="layui-input-block"><img id="verify_img" src="{:captcha_src()}" alt="captcha" style="width:70%;"  onclick="refreshVerify();"/></div>
               
            </div>
            <input value="登录" lay-submit lay-filter="login" style="width:100%;" type="button">

            <hr class="hr20">
            
        </form>
    </div>

    <script>
        $(function () {
            layui.use('form', function () {
                var form = layui.form;

                form.on('submit(login)', function (data) {
                    var formData = data.field;

                    $.ajax({
                        url: "{:url('check') }",
                        data: {
                            '__token__': formData.__token__,
                            'name': formData.name,
                            'password': formData.password,
                            'code': formData.code
                        },
                        type: "Post",
                        dataType: "json",
                        success: function (res) {
                            // console.log(res.data.token)
                            
                            layer.msg(res.msg);
                            if(res.code==1){
                                location.href="http://rbac.com/";
                            }
                            //   location.reload(); //删除成功后再刷新
                        }
                    })

                });


            });
        })
    </script>
    <script>
        function refreshVerify() {
            var ts = Date.parse(new Date())/1000;
            $('#verify_img').attr("src", "/captcha?id="+ts);
        }
    </script>
    <!-- 底部结束 -->

</body>

</html>